package C;

import java.util.HashSet;
import java.util.Scanner;

public class C2 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int l1 = sc.nextInt();
        int l2 = sc.nextInt();
        int[] A = new int[l1];
        int sumA = 0;
        for(int i = 0;i<l1;i++){
            A[i]=sc.nextInt();
            sumA+=A[i];
        }

        int sumB = 0;
        HashSet<Integer> B = new HashSet<>();
        for(int i=0;i<l2;i++){
            int b = sc.nextInt();
            B.add(b);
            sumB+=b;
        }

        int halfDiff = (sumA-sumB)/2;
        int minA = Integer.MAX_VALUE;
        String answer = "";
        for(int a:A){
            int b = a-halfDiff;
            if (B.contains(b)){
                if(a<minA){
                    minA = a;
                    answer = minA+" "+b;
                }
            }
        }
        System.out.println(answer);
    }
}
